package com.niiwoo.civet.account.service.dubbo.check;

import com.alibaba.dubbo.config.annotation.Service;
import com.niiwoo.civet.account.dao.entity.AccountCheckingAccountStatistics;
import com.niiwoo.civet.account.dao.mapper.AccountCheckingAccountStatisticsMapperExt;
import com.niiwoo.civet.account.dto.response.AccountCheckingAccountStatisticsDTO;
import com.niiwoo.civet.account.service.AccountCheckingStatisticsDubboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 查询当天账期期余余额
 */
@Slf4j
@Service(version = "1.0.0", validation = "true")
public class AccountCheckingStatisticsDubboServiceImpl implements AccountCheckingStatisticsDubboService {

    @Autowired
    private AccountCheckingAccountStatisticsMapperExt accountCheckingAccountStatisticsMapperExt;

    @Override
    public AccountCheckingAccountStatisticsDTO getBillDate(String billDate) {
        List<AccountCheckingAccountStatistics> accountCheckingAccountStatisticsList = accountCheckingAccountStatisticsMapperExt.selectByBillDate(billDate);
        if(accountCheckingAccountStatisticsList.size() != 1){
            log.error("{} account statistics error，accountCheckingAccountStatisticsList data error!",billDate);
            return null;
        }
        AccountCheckingAccountStatisticsDTO accountCheckingAccountStatisticsDTO = new AccountCheckingAccountStatisticsDTO();
        BeanUtils.copyProperties(accountCheckingAccountStatisticsList.get(0),accountCheckingAccountStatisticsDTO);
        return accountCheckingAccountStatisticsDTO;

    }
}
